/**
 * Copyright 2009 University of Washington This code is released under the GPL version 3 - with a copy of the license
 * included
 * 
 * @author Maya Hao Li
 */
package seedpod.webapp.view.htmlwidget;

public class CheckBoxInput extends GenericHtmlWidget {

	private boolean	_checked	= false;
	private String	_value		= "";

	public CheckBoxInput(String widgetID) {
		super( widgetID );
	}

	public CheckBoxInput(String widgetID, String value) {
		super( widgetID );
		_value = value; // Boolean.getBoolean( value );
	}

	public CheckBoxInput(String widgetID, String value, Boolean checked) {
		super( widgetID );
		_value = value;

		if ( checked == null ) _checked = false;
		else _checked = checked;
	}

	@Override
	public String render() {
		String view = "<input ";
		view += ATT( "type", "checkbox" );
		view += ATT( "class", _cssClass );
		view += ATT( "id", _widgetID );
		view += ATT( "name", _widgetID );
		view += ATT( "value", _value );
		if ( _checked ) view += "checked ";
		view += "> " + _value;
		return view;
	}

}